home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-06-24 | 5.3 KB | 184 lines | [TEXT/MPS ] |
- // Copyright © 1994-95 by Apple Computer, Inc. All rights reserved.
- // UShapes.h
-
- #ifndef __USHAPES__
- #define __USHAPES__
-
- #ifndef __UOBJECT__
- #include <UObject.h>
- #endif
-
- #ifndef __GEOMETRY__
- #include "Geometry.h"
- #endif
-
- #ifndef __TOOLBOX__
- #include "Toolbox.h"
- #endif
-
- //--------------------------------------------------------------------------------------------------
-
- class TFile;
- class TShapeView;
- class TView;
-
- //--------------------------------------------------------------------------------------------------
- // Constants
-
- // Shape ids
- const short IDBox = 1;
- const short IDCircle = 2;
- const short IDhBox = 3;
- const short IDTextShape = 4;
-
- //--------------------------------------------------------------------------------------------------
- // ShapeData: Information about a single shape;
- // same format used both in the data file and in the desk scrap.
-
- struct ShapeData {
- short theId; // 1 = rectangle; 2 = oval; etc.
- CRect theRect; // the shape's extent
- short thePattern; // the shape's current Pattern
- CRGBColor theColor; // the shape's current color
- Boolean theSelected; // for saving window state; not relevant for clipboard
- };
-
- typedef ShapeData* ShapeDataPtr;
-
- //--------------------------------------------------------------------------------------------------
- // CLASS TShape - abstract class
- //--------------------------------------------------------------------------------------------------
- class TShape : public TObject
- {
- MA_DECLARE_CLASS;
-
- public:
- TShape(); // Constructor
-
- void IShape(const CRect& itsFrame, short itsID);
- // Initialze a shape procedurally
-
- virtual void DoInitialState(TShapeView* itsView);
-
- // • I/O
- virtual void ReadFrom(TStream* aStream); // Override
- virtual void WriteTo(TStream* aStream); // Override
-
- // • Screen display
- virtual void Draw();
- virtual void DrawOutline();
- virtual void Highlight(HLState fromHL, HLState toHL, TView* itsView);
-
- // • Misc
- inline void GetColor(CRGBColor& itsColor) { itsColor = fColor; }
- inline short GetID() { return fIdentifier; };
- // Used so that a filed shape can identify what kind of shape object is
- // to be instantiated to represent it in memory
- inline short GetPattern() { return fPattern; };
- inline void ReplacePattern(short newPattern)
- { fOldPattern = fPattern;
- fPattern = newPattern;
- };
- inline void ReplaceColor(CRGBColor newColor)
- { fOldColor = fColor;
- fColor = newColor;
- };
-
- inline Boolean WasSelected() { return fWasSelected; };
- inline Boolean IsSelected() { return fIsSelected; };
- inline void SetSelected(Boolean isSelected) { fIsSelected = isSelected; };
- inline void SetWasSelected(Boolean wasSelected) { fWasSelected = wasSelected; };
- inline void SetIsWasSelected() { fIsSelected = fWasSelected; };
- inline void SetWasIsSelected() { fWasSelected = fIsSelected; };
-
- void SetFields(short pattern, CRGBColor color, CRect extentRect);
- // Used to initialize shapes created from the Clipboard
-
- void GetFrame(CRect& itsFrame);
- virtual void SetFrame(const CRect& extentRect);
-
- virtual void BeInView(TShapeView* itsView);
-
- short fPattern; // Pattern of object
- short fOldPattern; // old shade, for Reshade command Undo/Redo
- CRGBColor fColor; // color of object
- CRGBColor fOldColor; // old color, for Recolor command Undo/Redo
-
- protected:
- CPoint fLocation;
- CPoint fSize;
- short fIdentifier;
- Boolean fIsSelected; // is shape selected?
- Boolean fWasSelected; // old selection status, set when last command was performed
- };
-
- //--------------------------------------------------------------------------------------------------
- // CLASS TArrowTool
- //--------------------------------------------------------------------------------------------------
- class TArrowTool : public TShape
- {
- MA_DECLARE_CLASS;
-
- public:
- TArrowTool();
- void IArrowTool(CRect itsExtent, short itsID);
-
- virtual void Draw(); // Override
-
- protected:
- BitMap fArwBitMap; // bitmap used to draw arrow in palette
-
- };
-
- //--------------------------------------------------------------------------------------------------
- // CLASS TBox
- //--------------------------------------------------------------------------------------------------
- class TBox : public TShape
- {
- MA_DECLARE_CLASS;
-
- public:
- TBox();
- void IBox(CRect itsExtent, short itsID);
-
- virtual void Draw(); // Override
- virtual void DrawOutline(); // Override
- };
-
- //--------------------------------------------------------------------------------------------------
- // CLASS THeavyBox - like a TBox except uses up 4K bytes
- //--------------------------------------------------------------------------------------------------
- class THeavyBox : public TBox
- {
- MA_DECLARE_CLASS;
-
- public:
- THeavyBox();
- void IHeavyBox(CRect itsExtent, short itsID);
-
- virtual void ReadFrom(TStream* aStream); // Override
- virtual void WriteTo(TStream* aStream); // Override
-
- virtual void Draw(); // Override
-
- private:
- long fFiller[1024];
- };
-
- //--------------------------------------------------------------------------------------------------
- // CLASS TCircle
- //--------------------------------------------------------------------------------------------------
- class TCircle : public TShape
- {
- MA_DECLARE_CLASS;
-
- public:
- TCircle();
- void ICircle(CRect itsExtent, short itsID);
-
- virtual void Draw(); // Override
- virtual void DrawOutline(); // Override
- };
-
- #endif
-